package com.yunxi.service.dubboService.impl.otd;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.model.otd.OtdOrderMonthVersion;
import com.yunxi.otd.pojo.OtdOrderCirWeekVersionQueryVO;
import com.yunxi.otd.pojo.OtdOrderMonthVersionChangeStateVO;
import com.yunxi.otd.service.OtdOrderCirWeekVersionDubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import java.lang.reflect.InvocationTargetException;
import com.yunxi.otd.pojo.OtdOrderCirWeekVersionVO;
import java.util.Map;
import java.util.List;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunxi.service.localService.otd.OtdOrderCirWeekVersionService;
import com.yunxi.model.otd.OtdOrderCirWeekVersion;

/**
 * <p>
 * 周CIR预测版本管理 服务实现类
 * </p>
 *
 * @author XUQI
 * @since 2019-10-14
 */
public class OtdOrderCirWeekVersionDubboServiceImpl implements OtdOrderCirWeekVersionDubboService {

    @Autowired
    @Qualifier(value = "otdOrderCirWeekVersionServiceImpl")
    OtdOrderCirWeekVersionService otdOrderCirWeekVersionService;


    @Override
    public OtdOrderCirWeekVersionVO getById(String id) {
        OtdOrderCirWeekVersion otdOrderCirWeekVersion = otdOrderCirWeekVersionService.getById(id);
        OtdOrderCirWeekVersionVO otdOrderCirWeekVersionVO = new OtdOrderCirWeekVersionVO();
        BeanUtils.copyProperties(otdOrderCirWeekVersion, otdOrderCirWeekVersionVO);
        return otdOrderCirWeekVersionVO;
    }

    @Override
    public void saveOrUpdate(OtdOrderCirWeekVersionVO otdOrderCirWeekVersionVO) {
        OtdOrderCirWeekVersion otdOrderCirWeekVersion = new OtdOrderCirWeekVersion();
        BeanUtils.copyProperties(otdOrderCirWeekVersionVO, otdOrderCirWeekVersion);
        otdOrderCirWeekVersionService.saveOrUpdate(otdOrderCirWeekVersion);
    }

    /**
     * 删除版本
     *
     * @param ids ids
     * @return ApiResult
     */
    @Override
    public ApiResult removeByIds(List<String> ids) {
        return otdOrderCirWeekVersionService.removeByIds(ids);
    }

    @Override
    public PageInfo findPageByVO(OtdOrderCirWeekVersionQueryVO queryVO, Integer pageNum, Integer pageSize) {
        return otdOrderCirWeekVersionService.pageByVo(queryVO, pageNum, pageSize);
    }


    @Override
    public List listByVo(OtdOrderCirWeekVersionVO otdOrderCirWeekVersionVO) {
        return otdOrderCirWeekVersionService.listByVo(otdOrderCirWeekVersionVO);
    }

    @Override
    public ApiResult changeState(OtdOrderCirWeekVersionVO changeStateVO) {
        OtdOrderCirWeekVersion weekVersion = new OtdOrderCirWeekVersion();
        BeanUtils.copyProperties(changeStateVO, weekVersion);
        otdOrderCirWeekVersionService.updateById(weekVersion);
        return ResponseUtil.ok();
    }

    /**
     * 设置默认版本
     *
     * @param id id
     * @return ApiResult
     */
    @Override
    public ApiResult setDefault(String id) {
        return otdOrderCirWeekVersionService.setDefault(id);
    }
}
